package com.ruoyu.cloud.ai.mcp.service;

import com.ruoyu.cloud.ai.mcp.entity.Book;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Function;

@Service
public class BookQueryService {

    @Resource
    private BookService bookService;

    /**
     * 根据书名查询图书的函数Bean
     */
    @Bean
    public Function<String, List<Book>> findBooksByTitle() {
        return title -> bookService.findBooksByTitle(title);
    }

    /**
     * 根据作者查询图书的函数Bean
     */
    @Bean
    public Function<String, List<Book>> findBooksByAuthor() {
        return author -> bookService.findBooksByAuthor(author);
    }

    /**
     * 根据分类查询图书的函数Bean
     */
    @Bean
    public Function<String, List<Book>> findBooksByCategory() {
        return category -> bookService.findBooksByCategory(category);
    }

    /**
     * 根据分类查询图书的函数Bean
     */
    @Bean
    public Function<String, List<Book>> findBooks() {
        return request -> bookService.findBooks();
    }
}
